Skip to content

fix(parser): unify indirect subscript consumption - #2734

Merged
chaliy merged 2 commits into
mainfrom
fix/indirect-reference-consumption-f490
Oct 15, 2026
Merged

chaliy merged 2 commits into
mainfrom
fix/indirect-reference-consumption-f490

Conversation

@chaliy

@chaliy chaliy commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

What changed

Indirect references and ordinary parameter expansions now agree on where an
array subscript ends, including escaped and quoted closing brackets. A resolved
indirect target must consume exactly one complete reference before an explicit
caller-supplied suffix is appended.

Indirect reparses also share request work/cancellation state, inherit enclosing
command-substitution depth, and propagate deferred child-parser errors.

Why

The separate indirect validator and parameter parser used different escape and
quote rules. Text admitted as one subscript could be reinterpreted as an operator
operand downstream. Sharing the scanner removes this grammar disagreement while
retaining the existing exact-reference and restricted-substitution policies.

Before / After

Two tiny ordinary parser fixtures failed before the fix: an escaped-bracket key
became an array access plus leftover literal text, and an explicitly supplied
default operator was attached at the wrong boundary. After the change the key
is one complete array reference and the explicit default remains attached to it.

Safe local validation is refreshed after merging current main 41ea8ab3 into
the existing branch without rewriting history:

  • Six unit fixtures: escaped/quoted/nested reference consumption, exact boundary
    admission, shared work/cancellation, inherited depth, and two existing ordinary
    parser compatibility checks.
  • Four finite integration fixtures: nested-index Bash parity, escaped/quoted
    associative keys, explicit default/slice Bash parity, and malformed ordinary
    trailing text with session recovery.
  • Lean clippy with warnings denied, formatting, OKF, and documentation links.

No direct recursive/resource-exhaustion reproducer was executed or added. Normal
unchanged CI provides the repository's complete gate; no CI or test policy is
changed by this PR.

Risk

  • Medium: shared parser boundary handling affects array parameter syntax.
  • Valid nested references and explicit caller suffixes remain covered. Existing
    modern-Bash rejection of trailing indirect-target text is preserved.
  • No dependency, cap, stack-size, release, Input-module, or publication changes.
  • Security review: grammar admission, UTF-8 boundaries, request-budget ownership,
    cancellation, child depth, and error propagation. Canonical TM-DOS-135 and its
    public summary are updated with the implementation.

Checklist

  • Tests added or updated
  • Backward compatibility considered

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit c1fbd69 Commit Preview URL

Branch Preview URL
Oct 15 2026, 06:29 PM

@chaliy
chaliy merged commit 2bafa06 into main Oct 15, 2026
50 checks passed
@chaliy
chaliy deleted the fix/indirect-reference-consumption-f490 branch October 15, 2026 18:58
@chaliy
chaliy restored the fix/indirect-reference-consumption-f490 branch October 15, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant